package com.evildog.workspace.system.application.convert;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.evildog.workspace.common.result.PagedResult;
import com.evildog.workspace.system.application.bo.RoleBO;
import com.evildog.workspace.system.application.bo.RoleListBO;
import com.evildog.workspace.system.application.bo.RolePageBO;
import com.evildog.workspace.system.application.bo.RoleUiPermissionBO;
import com.evildog.workspace.system.application.dto.RoleDTO;
import com.evildog.workspace.system.application.dto.RoleListDTO;
import com.evildog.workspace.system.application.dto.RolePageDTO;
import com.evildog.workspace.system.application.dto.RoleUpdateUiPermissionDTO;
import com.evildog.workspace.system.application.entity.Role;
import com.evildog.workspace.system.application.entity.RoleListDO;
import com.evildog.workspace.system.application.entity.RolePageDO;
import com.evildog.workspace.system.application.model.RoleEditParam;
import com.evildog.workspace.system.application.model.RoleListParam;
import com.evildog.workspace.system.application.model.RolePageParam;
import com.evildog.workspace.system.application.model.RoleUpdateUiPermissionParam;
import com.evildog.workspace.system.application.vo.RoleListVO;
import com.evildog.workspace.system.application.vo.RolePageVO;
import com.evildog.workspace.system.application.vo.RoleUiPermissionVO;
import com.evildog.workspace.system.application.vo.RoleVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface RoleConvert {

    RoleConvert INSTANCE = Mappers.getMapper(RoleConvert.class);

    RolePageDTO convert(RolePageParam rolePageParam);

    RoleDTO convert(RoleEditParam roleEditParam);

    @Mapping(target = "isDeleted", ignore = true)
    Role convert(RoleDTO roleDTO);

    RolePageDO convert(RolePageDTO rolePageDTO);

    RoleVO convert(RoleBO roleBO);

    RoleBO convert(Role role);

    List<RoleListBO> convert(List<RoleListDO> roleList);

    List<RoleListVO> convertVoList(List<RoleListBO> roleListBO);

    @Mappings({})
    PagedResult<RolePageBO> convert(IPage<RolePageDO> page);

    PagedResult<RolePageVO> convert(PagedResult<RolePageBO> page);

    @Mappings({
            @Mapping(target = "componentPermissions", source = "componentPermissionIds"),
            @Mapping(target = "menuPermissions", source = "menuPermissionIds")
    })
    RoleUpdateUiPermissionDTO convert(RoleUpdateUiPermissionParam param);

    RoleUiPermissionVO convert(RoleUiPermissionBO allUiPermissions);

    RoleListDTO convert(RoleListParam param);

    List<RoleListVO> convertVOList(List<RoleListBO> roleList);

    List<RoleListBO> convertBoList(List<Role> validRolesByUserGroup);
}